package com.biz.primus.ms.depot.dao.repository;

import com.biz.primus.ms.base.jpa.repository.CommonJpaRepository;
import com.biz.primus.ms.depot.dao.po.Employee;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.sql.Timestamp;
import java.util.List;

/**
 * @author JKLiues
 * @date 2017/10/12
 */
@Repository
public interface EmployeeRepository extends CommonJpaRepository<Employee, Long>, EmployeeDao {

    /**
     * 员工编码查员工
     *
     * @param employeeCode 员工编码
     * @param time         时间
     * @return Employee
     */
    @Query("select o from Employee o where o.employeeCode = ?1 and ?2 between o.beginTime and o.endTime")
    Employee findByEmployeeCodeAndTime(String employeeCode, Timestamp time);

    /**
     * 员工编码查员工
     *
     * @param employeeCode 员工编码集
     * @return List<Employee>
     */
    List<Employee> findByEmployeeCode(String employeeCode);

    /**
     * 查当前生效的员工信息
     *
     * @param depotCode 门店编码
     * @param time      当前时间
     * @return List<Employee>
     */
    @Query("select o from Employee o where o.depotCode = ?1 and ?2 between o.beginTime and o.endTime")
    List<Employee> findByDepotCode(String depotCode, Timestamp time);
}
